package com.han.neo4jjava.controller;

import com.han.neo4jjava.core.person.Person;
import com.han.neo4jjava.core.person.PersonQueryService;
import com.han.neo4jjava.core.person.PersonRepo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/persons")
public class PersonController {

    private final PersonQueryService personQueryService;

    @GetMapping()
    public List<Person> list() {
        return personQueryService.findAll();
    }

    @GetMapping("/{name}")
    public List<Person> list(@PathVariable String name) {
        return personQueryService.queryAllByName(name);
    }

}
